[contents]
[prev] [next]
[top] [bottom]
(2 out of 5)
The ScriptX Language
The following section describes the main features of the
ScriptX language:
- Programs written in the ScriptX language are compiled into
a fast, portable form called bytecode. The bytecode
compiler is part of the ScriptX Language and Class Library.
Complete ScriptX titles consist of scripts in this bytecode
form, plus media content. Titles are compiled into
platform-independent bytecode which runs on the Kaleida Media
Player for each platform. The bytecode compiler allows ScriptX
programs to have both the flexibility of an interpreted
language and the speed of a compiled language. Compilation is
immediate and interactive. ScriptX is characterized as a
scripting language in part because classes, objects,
functions, and methods can be created and compiled
incrementally. New methods can be added to an existing class,
or an instance of a class, without recompilation.
- ScriptX is a pure object system. ScriptX is uniformly
object oriented. In ScriptX, in contrast with C++, every value
is an object reference. Many object-oriented languages allow a
mixture of object and non-object types. ScriptX does not. In
ScriptX, every unit of information is an object. Every
construct in the language is an expression, and every
expression returns an object. Every operand in every operation
is an object. Some core classes do store information
internally that is not in the form of an object. For example,
individual characters in a string are not objects. However, in
the ScriptX language, such data can only be evaluated and
manipulated as objects.
- The ScriptX language is rooted in the Kaleida object
system and the core classes. This differs from C++, in which,
at least in theory, a developer might begin a new application
by developing the equivalent of
RootObject
for
that application. (In ScriptX, RootObject
is the
root system class from which all other classes in the
application inherit.)
- ScriptX implements latent typing of variables,
also known as dynamic typing. This contrasts with static
typing in both C and C++. Static typing means that type
is associated with the location the value is assigned to, not
with the value itself. By contrast, latent typing means that
type is associated with and intrinsic to the object itself.
Static typing requires an explicit declaration of type for any
location that stores a value. With static typing, all types
that can be used in a program must be declared at compile
time. With latent typing in ScriptX, a location does not
actually store a value, but rather a reference to an object,
generally stored elsewhere. One could say that all ScriptX
variables are of a single type-object reference. In
practice, this means that type checking is associated not with
the compiler but with the object itself. Type checking, which
is optional, can be performed at runtime.
- ScriptX allows any variable to store a reference to any
object. In untyped languages, expressiveness is limited by the
ability of the language to parse and interpret data from the
input stream. Lingo, ToolScript, and Hypertalk-untyped
languages that are popular with existing multimedia authoring
tools-accept only data that can be represented as a string. In
these languages, data is stored and manipulated in other forms
internally, but all data must be represented implicitly as a
string in a program. ScriptX has a single data type, an object
reference, which has the flexibility to accommodate every kind
of data and program construct, including classes, objects,
functions, methods, modules, directories, and files.
- ScriptX allow objects to be assigned to variables at
runtime, a feature known as dynamic binding. This
allows new objects to be imported into a program to interact
with existing objects. If these objects understand a common
set of protocols, they can communicate at runtime. Dynamic
binding allows programmers to create a style of program that
is open-ended. For example, a title developer could ship a new
set of scenes and characters to complement an existing title.
- ScriptX offers a full range of control structures,
including branching, case statements, for loops, and repeat
loops that terminate at either the beginning or the end of the
loop. The ScriptX for loop is notable in that it can iterate
over the members of a range or collection of objects. ScriptX
control structures are implemented as expressions that return
values. This allows control structures to be nested within
other control structures.
- ScriptX is modular. Using modules, a programmer can
specify well-defined interfaces to programming libraries.
Through the use of modules, a programmer can protect a
program's namespace. Modules allow groups of programmers to
collaborate on large programming tasks.
This document is part of the ScriptX Language Guide, one of the volumes of the ScriptX Technical Reference Series. ScriptX is developed by the ScriptX Engineering Team at Apple Computer, successor to the Kaleida Engineering Team at Kaleida Labs, Inc.
Copyright 1996 Apple Computer, Inc. All Rights Reserved.